package com.kushe.entity;

import com.kushe.util.core.DbUtils;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Table;

import java.util.Date;

/**
 * Created by WhiteBlue on 15/4/3.
 */
@Table("ks_design")
public class Design {

    @Id
    private int id;

    @Column
    private String name;

    @Column
    private String content;

    @Column
    private double price;

    @Column
    private int user_id;

    @Column
    private int sort_id;

    @Column
    private int category_id;

    @Column
    private Date time;


    @Column
    private int type;

    @Column
    private int count;

    @Column
    private String img;


    @One(target = User.class, field = "user_id")
    private User user;

    @One(target = Sort.class, field = "sort_id")
    private Sort sort;


    @One(target = Category.class, field = "category_id")
    private Category category;


    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public User getUser() {
        if (this.user == null) {
            DbUtils.getNutzDao().fetchLinks(this, "user");
            return this.user;
        } else
            return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Sort getSort() {
        if (this.sort == null) {
            DbUtils.getNutzDao().fetchLinks(this, "sort");
            return this.sort;
        } else
            return this.sort;
    }

    public int getCategory_id() {
        return category_id;
    }

    public void setCategory_id(int category_id) {
        this.category_id = category_id;
    }

    public Category getCategory() {
        if (this.category == null) {
            DbUtils.getNutzDao().fetchLinks(this, "category");
            return this.category;
        } else
            return this.category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public void setSort(Sort sort) {
        this.sort = sort;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getUser_id() {
        return user_id;
    }

    public void setUser_id(int user_id) {
        this.user_id = user_id;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }


    public int getSort_id() {
        return sort_id;
    }

    public void setSort_id(int sort_id) {
        this.sort_id = sort_id;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

}
